<?php
Class Committee_Model extends CI_Model{
   
    function view_type()
    {
        $this->db->select('committee_type');
        $this->db->distinct();
        $query=$this->db->get('committee_list');
        return $query;
    }
    function view_committee($type_name='*')
    {
        $this->db->order_by('committee_name');
        if ($type_name=='*') return $this->db->get('committee_list');
        $this -> db -> where('committee_type',$type_name);
        $query=$this->db->get('committee_list');
        return $query;
    }
    function view_faculty()
    {
        $this->db->order_by("faculty_name", "asc");
        $query=$this->db->get('faculty');
        return $query;
    }
    function view_member($committee_name)
    {
        $this -> db -> where('committee_name',$committee_name);
        $query=$this->db->get('committee_member');
        return $query;
    }
    function getname($uniqueid)
    {
        $this->db->where('uniqueid',$uniqueid);
        $query=$this->db->get('faculty');
        $row=$query->row();
        return $row->faculty_name;
        
    }
    function add_committee($type,$name)
    {
        $data=array();
        $data['committee_type']=$type;
        $data['committee_name']=$name;
        $this->db->insert('committee_list',$data);
    }
    function add_member($data)
    {
        $this->db->insert('committee_member',$data);
    }
}